﻿using System;
using System.Xml.Serialization;
using Infrastructure;
using SceneUnpacker.se.gno;

namespace Extractor.Manager.Entities
{
    
    public class ArchiveFile
    {
        public string FileName { get; set; }

        public string FullFileName { get; set; }

        public Status Status { get; set; }

        public string PickupFolder { get; set; }

        public string ExtractedFolder { get; set; }

        public DateTime AddOn { get; set; }

        public DateTime? StartedOn { get; set; }

        public DateTime? DoneOn { get; set; }

        [XmlIgnore]
        public Archive Archive { get; private set; }
       
        public int Percentage { get; set; }
       
        public ArchiveFile()
        {

        }

        public ArchiveFile ( Archive archive )
        {
            if ( archive == null ) throw new ArgumentNullException( "archive" );
            Archive = archive;

            FullFileName = archive.File.FullName;
            PickupFolder = archive.Directory.FullName;
            FileName = archive.File.Name;
            AddOn = DateTime.Now;
            Status = Status.New;
        }

        public void MarkedAsExtracting()
        {
            Status = Status.Process;
            StartedOn = DateTime.Now;
        }

        public void MarkedAsDone(string extractedFolder)
        {
            Status = Status.Sucess;
            ExtractedFolder = extractedFolder;
            DoneOn = DateTime.Now;
        }

        public void IgnoreFile()
        {
            Status = Status.Ignored;
        }
    }
}
